<template>
  <div style="height: 523px;overflow: hidden;background: white;border: 1px solid white; border-radius: 12px; margin-top: 10px ">
    
    <div style="background-color: white; height: 20px; text-align: left; padding: 10px; margin-top: 15px;">
      <h4>当前等待登记的出库登记总数：3例

      </h4>
    </div>
    <div style="background-color: #E9EEF3; height: 400px; margin: 10px; padding: 4px; border-radius: 7px;">
      <template>
        <el-table :data="tableData" style="width: 100% ">
				
          <el-table-column prop="chukudanid" label="出库单编号" width="320">
          </el-table-column>
          <el-table-column prop="chufangchushi" label="出库理由" width="180">
          </el-table-column>
          <el-table-column prop="timekc" label="登记时间" width="100">
          </el-table-column>
          <el-table-column prop="chukuzonjianshu" label="总件数" width="100">
          </el-table-column>
          <el-table-column prop="chukuzonjine" label="总金额(元)" width="100">
          </el-table-column>
  	<el-table-column label="登记" width="100">
     <template slot-scope="scope">
        	 <el-button size="mini" @click.native.prevent="dj(scope.row.chukudanid)" round>登记</el-button>
    </template>
  </el-table-column>
         
        </el-table>
      </template>
      <div class="block" style="position: absolute; bottom: 65px; margin-left:250px ;">
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="14"
          :page-sizes="[100, 200, 300, 400]" :page-size="100" layout="total, sizes, prev, pager, next, jumper"
          :total="400">
        </el-pagination>
      </div>
    </div>

<el-dialog style="position: absolute; top: -78px;" title="入库登记" :visible.sync="dialogVisible" width="90%"
				  :before-close="handleClose">
				  <el-table :data="tableDataa" size="mini">
				    <el-table-column property="cpbh" label="产品编号" width="180"></el-table-column>
						<el-table-column property="cpmc" label="产品名称" width="190"></el-table-column>
				    <el-table-column property="chufangchushi" label="库房名称" width="190"></el-table-column>
						<el-table-column property="qimukucun" label="当前库存数量" width="160"></el-table-column>
				    <el-table-column property="chukushuliang" label="应入库件数" width="160"></el-table-column>
				    <el-table-column property="yichukushuliang" label="已入库件数" width="160"></el-table-column>
						<el-table-column label="本次入库数量" width="200">
						<template slot-scope="scope">
							<ddd v-if="scope.row.yichukushuliang!=scope.row.chukushuliang">
            <input type="text" v-model="scope.row.yinchukushuliang" id="inp" style=" margin-top: 20px;"/>
					</ddd>
					<ddd v-else>
						已完成
					</ddd>
										</template>
						</el-table-column>
						 
				  </el-table>
				  <div class="block" style="margin-top: 14px;">
				    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
				      :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]" :page-size="100"
				      layout="total, sizes, prev, pager, next, jumper" :total="400">
				    </el-pagination>
				  </div>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="dialogVisible = false">取 消</el-button>
				    <el-button type="primary" @click="rukuint">确 定</el-button>
				  </span>
				</el-dialog>
		
  </div>
</template>

<script>
  export default {
    name: 'repoutsh',
    data() {
      return {
        table: false,
        dialog: false,
        loading: false,
        tableData: [],
				tableDataa:[],
        dialogTableVisible: false,
        dialogFormVisible: false,
				dialogVisible:false,
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        formLabelWidth: '80px',
        timer: null
      }
    },
				mounted(){
			this.$http.post("seldjRepwltddateis")
			.then((res) => {	 	
							 this.tableData=res.data;						 
					})
					.catch((err) => { //请求失败
				console.log(err);
			}); 
		},
		methods: {
			dj(row){
				var demo=new URLSearchParams()
				demo.append("chukudanid",row)
				this.$http.post("seliddjRepwltddateis",demo)
				.then((res) => {	 	
								 this.tableDataa=res.data;						 
						})
						.catch((err) => { //请求失败
					console.log(err);
				}); 
			this.dialogVisible=true;
		},
		rukuint(){
			this.tableDataa.forEach((item)=>{
				  if(item.yichukushuliang!=item.chukushuliang&&item.yinchukushuliang<=item.chukushuliang&&item.yinchukushuliang>0&&item.yinchukushuliang<=(item.chukushuliang-item.yichukushuliang)){
						var demo=new URLSearchParams()
						demo.append("chukuid",item.chukudanid)
						demo.append("yirukunum",item.yinchukushuliang)
						demo.append("ReviewSigng","等待复核")
						this.$http.post("updidRepwltddateiss",demo)
							.then((res) => {	
										 this.tableDataa=res.data;
										 this.dialogVisible=false;											
								})
								.catch((err) => { //请求失败
							console.log(err);
						     	}); 
					}else{
							 var demo2=new URLSearchParams()
							 demo2.append("ReviewSigng","已复核")
							 demo2.append("chukuid",item.chukudanid)
						 this.$http.post("updidfhtgRepwltddateiss",demo2)
								.then((res) => {	 	
								 this.tableDataa=res.data;
										 })
									.catch((err) => { //请求失败
										console.log(err);
								}); 
					}
			})
		},
		  tableRowClassName({
		    row,
		    rowIndex
		  }) {
		    if (rowIndex === 1) {
		      return 'warning-row';
		    } else if (rowIndex === 3) {
		      return 'success-row';
		    }
		    return '';
		  },
		  handleSizeChange(val) {
		    console.log(`每页 ${val} 条`);
		  },
		  handleCurrentChange(val) {
		    console.log(`当前页: ${val}`);
		  },
		  handleClose(done) {
		    if (this.loading) {
		      return;
		    }
		    this.$confirm('确定要提交表单吗？')
		      .then(_ => {
		        this.loading = true;
		        this.timer = setTimeout(() => {
		          done();
		          // 动画关闭需要一定的时间
		          setTimeout(() => {
		            this.loading = false;
		          }, 400);
		        }, 2000);
		      })
		      .catch(_ => {});
		  },
		  cancelForm() {
		    this.loading = false;
		    this.dialog = false;
		    clearTimeout(this.timer);
		
		  }
		}
  }
</script>

<style scoped="scoped">
  * {
    padding: 0px;
    margin: 0px;
  }

  .el-breadcrumb__inner {
    color: black;

  }

  .el-input__inner {

    height: 25px;

  }

  .el-input__prefix,
  .el-input__suffix {
    position: absolute;
    top: 7px;
    -webkit-transition: all .3s;
    height: 100%;
    color: #C0C4CC;
    text-align: center;
  }

  .el-table td {
    padding: 10px 0;
  }
</style>
